import numpy as np
import tensorflow.compat.v2 as tf
tf.enable_v2_behavior()
import pandas as pd
from tensorflow import keras
from sklearn.preprocessing import StandardScaler
from sklearn.preprocessing import RobustScaler
from sklearn.preprocessing import MinMaxScaler
from matplotlib import pyplot
import plotly.graph_objects as go
import math
import seaborn as sns
from sklearn.metrics import mean_squared_error
np.random.seed(1)
tf.random.set_seed(1)
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, LSTM, GRU, Dropout, RepeatVector, TimeDistributed
from keras import backend
MODELFILENAME = 'MODELS/GRU_7d_TFM_2c'
TIME_STEPS=864 #6d
CMODEL = GRU
MODEL = "GRU"
UNITS=43
DROPOUT1=0.405
DROPOUT2=0.331
ACTIVATION='sigmoid'
OPTIMIZER='adam'
EPOCHS=56
BATCHSIZE=11
VALIDATIONSPLIT=0.1
# Code to read csv file into Colaboratory:
# from google.colab import files
# uploaded = files.upload()
# import io
# df = pd.read_csv(io.BytesIO(uploaded['SentDATA.csv']))
# Dataset is now stored in a Pandas Dataframe
df = pd.read_csv('../../data/dadesTFM.csv')
df.reset_index(inplace=True)
df['Time'] = pd.to_datetime(df['Time'])
df = df.set_index('Time')
columns = ['PM1','PM25','PM10','PM1ATM','PM25ATM','PM10ATM']
df1 = df.copy();
df1 = df1.rename(columns={"PM 1":"PM1","PM 2.5":"PM25","PM 10":"PM10","PM 1 ATM":"PM1ATM","PM 2.5 ATM":"PM25ATM","PM 10 ATM":"PM10ATM"})
df1['PM1'] = df['PM 1'].astype(np.float32)
df1['PM25'] = df['PM 2.5'].astype(np.float32)
df1['PM10'] = df['PM 10'].astype(np.float32)
df1['PM1ATM'] = df['PM 1 ATM'].astype(np.float32)
df1['PM25ATM'] = df['PM 2.5 ATM'].astype(np.float32)
df1['PM10ATM'] = df['PM 10 ATM'].astype(np.float32)
df2 = df1.copy()
train_size = int(len(df2) * 0.8)
test_size = len(df2) - train_size
train, test = df2.iloc[0:train_size], df2.iloc[train_size:len(df2)]
train.shape, test.shape
((3991, 7), (998, 7))
#Standardize the data
for col in columns:
scaler = StandardScaler()
train[col] = scaler.fit_transform(train[[col]])
<ipython-input-6-83cecdbc25f8>:4: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy train[col] = scaler.fit_transform(train[[col]]) <ipython-input-6-83cecdbc25f8>:4: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy train[col] = scaler.fit_transform(train[[col]]) <ipython-input-6-83cecdbc25f8>:4: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy train[col] = scaler.fit_transform(train[[col]]) <ipython-input-6-83cecdbc25f8>:4: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy train[col] = scaler.fit_transform(train[[col]]) <ipython-input-6-83cecdbc25f8>:4: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy train[col] = scaler.fit_transform(train[[col]]) <ipython-input-6-83cecdbc25f8>:4: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy train[col] = scaler.fit_transform(train[[col]])
def create_sequences(X, y, time_steps=TIME_STEPS):
Xs, ys = [], []
for i in range(len(X)-time_steps):
Xs.append(X.iloc[i:(i+time_steps)].values)
ys.append(y.iloc[i+time_steps])
return np.array(Xs), np.array(ys)
X_train, y_train = create_sequences(train[[columns[1]]], train[columns[1]])
#X_test, y_test = create_sequences(test[[columns[1]]], test[columns[1]])
print(f'X_train shape: {X_train.shape}')
print(f'y_train shape: {y_train.shape}')
X_train shape: (3127, 864, 1) y_train shape: (3127,)
#afegir nova mètrica
def rmse(y_true, y_pred):
return backend.sqrt(backend.mean(backend.square(y_pred - y_true), axis=-1))
model = Sequential()
model.add(CMODEL(units = UNITS, return_sequences=True, input_shape=(X_train.shape[1], X_train.shape[2])))
model.add(Dropout(rate=DROPOUT1))
model.add(CMODEL(units = UNITS, return_sequences=True))
model.add(Dropout(rate=DROPOUT2))
model.add(TimeDistributed(Dense(1,kernel_initializer='normal',activation=ACTIVATION)))
model.compile(optimizer=OPTIMIZER, loss='mae',metrics=['mse',rmse])
model.summary()
Model: "sequential" _________________________________________________________________ Layer (type) Output Shape Param # ================================================================= gru (GRU) (None, 864, 43) 5934 _________________________________________________________________ dropout (Dropout) (None, 864, 43) 0 _________________________________________________________________ gru_1 (GRU) (None, 864, 43) 11352 _________________________________________________________________ dropout_1 (Dropout) (None, 864, 43) 0 _________________________________________________________________ time_distributed (TimeDistri (None, 864, 1) 44 ================================================================= Total params: 17,330 Trainable params: 17,330 Non-trainable params: 0 _________________________________________________________________
history = model.fit(X_train, y_train, epochs=EPOCHS, batch_size=BATCHSIZE, validation_split=VALIDATIONSPLIT,
callbacks=[keras.callbacks.EarlyStopping(monitor='val_loss', patience=5, mode='min')], shuffle=False)
Epoch 1/56 256/256 [==============================] - 172s 672ms/step - loss: 0.7589 - mse: 1.1618 - rmse: 0.7596 - val_loss: 0.8198 - val_mse: 0.6969 - val_rmse: 0.8199 Epoch 2/56 256/256 [==============================] - 191s 746ms/step - loss: 0.6817 - mse: 1.0558 - rmse: 0.6820 - val_loss: 0.8160 - val_mse: 0.6906 - val_rmse: 0.8161 Epoch 3/56 256/256 [==============================] - 185s 723ms/step - loss: 0.6807 - mse: 1.0556 - rmse: 0.6808 - val_loss: 0.8150 - val_mse: 0.6890 - val_rmse: 0.8151 Epoch 4/56 256/256 [==============================] - 163s 638ms/step - loss: 0.6803 - mse: 1.0555 - rmse: 0.6804 - val_loss: 0.8145 - val_mse: 0.6882 - val_rmse: 0.8146 Epoch 5/56 256/256 [==============================] - 165s 646ms/step - loss: 0.6801 - mse: 1.0554 - rmse: 0.6802 - val_loss: 0.8143 - val_mse: 0.6878 - val_rmse: 0.8143 Epoch 6/56 256/256 [==============================] - 138s 539ms/step - loss: 0.6800 - mse: 1.0554 - rmse: 0.6800 - val_loss: 0.8141 - val_mse: 0.6875 - val_rmse: 0.8141 Epoch 7/56 256/256 [==============================] - 105s 410ms/step - loss: 0.6799 - mse: 1.0554 - rmse: 0.6800 - val_loss: 0.8140 - val_mse: 0.6873 - val_rmse: 0.8140 Epoch 8/56 256/256 [==============================] - 103s 403ms/step - loss: 0.6799 - mse: 1.0554 - rmse: 0.6799 - val_loss: 0.8139 - val_mse: 0.6871 - val_rmse: 0.8139 Epoch 9/56 256/256 [==============================] - 103s 404ms/step - loss: 0.6798 - mse: 1.0553 - rmse: 0.6798 - val_loss: 0.8139 - val_mse: 0.6871 - val_rmse: 0.8139 Epoch 10/56 256/256 [==============================] - 104s 407ms/step - loss: 0.6798 - mse: 1.0553 - rmse: 0.6798 - val_loss: 0.8138 - val_mse: 0.6870 - val_rmse: 0.8138 Epoch 11/56 256/256 [==============================] - 104s 405ms/step - loss: 0.6798 - mse: 1.0553 - rmse: 0.6798 - val_loss: 0.8138 - val_mse: 0.6869 - val_rmse: 0.8138 Epoch 12/56 256/256 [==============================] - 104s 406ms/step - loss: 0.6798 - mse: 1.0553 - rmse: 0.6798 - val_loss: 0.8138 - val_mse: 0.6869 - val_rmse: 0.8138 Epoch 13/56 256/256 [==============================] - 104s 407ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8138 - val_mse: 0.6868 - val_rmse: 0.8138 Epoch 14/56 256/256 [==============================] - 104s 407ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6868 - val_rmse: 0.8137 Epoch 15/56 256/256 [==============================] - 104s 405ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6868 - val_rmse: 0.8137 Epoch 16/56 256/256 [==============================] - 104s 407ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6868 - val_rmse: 0.8137 Epoch 17/56 256/256 [==============================] - 104s 407ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6868 - val_rmse: 0.8137 Epoch 18/56 256/256 [==============================] - 104s 405ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6868 - val_rmse: 0.8137 Epoch 19/56 256/256 [==============================] - 107s 419ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6868 - val_rmse: 0.8137 Epoch 20/56 256/256 [==============================] - 103s 402ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6868 - val_rmse: 0.8137 Epoch 21/56 256/256 [==============================] - 104s 408ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 22/56 256/256 [==============================] - 108s 422ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 23/56 256/256 [==============================] - 112s 439ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 24/56 256/256 [==============================] - 122s 477ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 25/56 256/256 [==============================] - 125s 490ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 26/56 256/256 [==============================] - 127s 497ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 27/56 256/256 [==============================] - 120s 470ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 28/56 256/256 [==============================] - 112s 438ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 29/56 256/256 [==============================] - 106s 412ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 30/56 256/256 [==============================] - 103s 403ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 31/56 256/256 [==============================] - 102s 400ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 32/56 256/256 [==============================] - 103s 403ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 33/56 256/256 [==============================] - 103s 403ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 34/56 256/256 [==============================] - 103s 401ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 35/56 256/256 [==============================] - 103s 404ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 36/56 256/256 [==============================] - 103s 402ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 37/56 256/256 [==============================] - 103s 402ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 38/56 256/256 [==============================] - 106s 414ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 39/56 256/256 [==============================] - 108s 421ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 40/56 256/256 [==============================] - 111s 434ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 41/56 256/256 [==============================] - 129s 506ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 42/56 256/256 [==============================] - 120s 469ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 43/56 256/256 [==============================] - 114s 444ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 44/56 256/256 [==============================] - 109s 427ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 45/56 256/256 [==============================] - 105s 411ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 46/56 256/256 [==============================] - 104s 408ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 47/56 256/256 [==============================] - 105s 409ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 48/56 256/256 [==============================] - 104s 406ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 49/56 256/256 [==============================] - 104s 407ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 50/56 256/256 [==============================] - 104s 405ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137 Epoch 51/56 256/256 [==============================] - 105s 409ms/step - loss: 0.6797 - mse: 1.0553 - rmse: 0.6797 - val_loss: 0.8137 - val_mse: 0.6867 - val_rmse: 0.8137
import matplotlib.pyplot as plt
plt.plot(history.history['loss'], label='MAE Training loss')
plt.plot(history.history['val_loss'], label='MAE Validation loss')
plt.plot(history.history['mse'], label='MSE Training loss')
plt.plot(history.history['val_mse'], label='MSE Validation loss')
plt.plot(history.history['rmse'], label='RMSE Training loss')
plt.plot(history.history['val_rmse'], label='RMSE Validation loss')
plt.legend();
X_train_pred = model.predict(X_train, verbose=0)
train_mae_loss = np.mean(np.abs(X_train_pred - X_train), axis=1)
plt.hist(train_mae_loss, bins=50)
plt.xlabel('Train MAE loss')
plt.ylabel('Number of Samples');
def evaluate_prediction(predictions, actual, model_name):
errors = predictions - actual
mse = np.square(errors).mean()
rmse = np.sqrt(mse)
mae = np.abs(errors).mean()
print(model_name + ':')
print('Mean Absolute Error: {:.4f}'.format(mae))
print('Root Mean Square Error: {:.4f}'.format(rmse))
print('Mean Square Error: {:.4f}'.format(mse))
print('')
return mae,rmse,mse
mae,rmse,mse = evaluate_prediction(X_train_pred, X_train,MODEL)
GRU: Mean Absolute Error: 0.6885 Root Mean Square Error: 1.0159 Mean Square Error: 1.0321
model.save(MODELFILENAME+'.h5')
#càlcul del threshold de test
def calculate_threshold(X_test, X_test_pred):
distance = np.sqrt(np.mean(np.square(X_test_pred - X_test),axis=1))
"""Sorting the scores/diffs and using a 0.80 as cutoff value to pick the threshold"""
distance.sort();
cut_off = int(0.8 * len(distance));
threshold = distance[cut_off];
return threshold
for col in columns:
print ("####################### "+col +" ###########################")
#Standardize the test data
scaler = StandardScaler()
test_cpy = test.copy()
test[col] = scaler.fit_transform(test[[col]])
#creem seqüencia amb finestra temporal per les dades de test
X_test1, y_test1 = create_sequences(test[[col]], test[col])
print(f'Testing shape: {X_test1.shape}')
#evaluem el model
eval = model.evaluate(X_test1, y_test1)
print("evaluate: ",eval)
#predim el model
X_test1_pred = model.predict(X_test1, verbose=0)
evaluate_prediction(X_test1_pred, X_test1,MODEL)
#càlcul del mae_loss
test1_mae_loss = np.mean(np.abs(X_test1_pred - X_test1), axis=1)
test1_rmse_loss = np.sqrt(np.mean(np.square(X_test1_pred - X_test1),axis=1))
# reshaping test prediction
X_test1_predReshape = X_test1_pred.reshape((X_test1_pred.shape[0] * X_test1_pred.shape[1]), X_test1_pred.shape[2])
# reshaping test data
X_test1Reshape = X_test1.reshape((X_test1.shape[0] * X_test1.shape[1]), X_test1.shape[2])
threshold_test = calculate_threshold(X_test1Reshape,X_test1_predReshape)
test1_score_df = pd.DataFrame(test[TIME_STEPS:])
test1_score_df['loss'] = test1_rmse_loss.reshape((-1))
test1_score_df['threshold'] = threshold_test
test1_score_df['anomaly'] = test1_score_df['loss'] > test1_score_df['threshold']
test1_score_df[col] = test[TIME_STEPS:][col]
#gràfic test lost i threshold
fig = go.Figure()
fig.add_trace(go.Scatter(x=test1_score_df.index, y=test1_score_df['loss'], name='Test loss'))
fig.add_trace(go.Scatter(x=test1_score_df.index, y=test1_score_df['threshold'], name='Threshold'))
fig.update_layout(showlegend=True, title='Test loss vs. Threshold')
fig.show()
#Posem les anomalies en un array
anomalies1 = test1_score_df.loc[test1_score_df['anomaly'] == True]
anomalies1.shape
print('anomalies: ',anomalies1.shape); print();
#Gràfic dels punts i de les anomalíes amb els valors de dades transformades per verificar que la normalització que s'ha fet no distorssiona les dades
fig = go.Figure()
fig.add_trace(go.Scatter(x=test1_score_df.index, y=scaler.inverse_transform(test1_score_df[col]), name=col))
fig.add_trace(go.Scatter(x=anomalies1.index, y=scaler.inverse_transform(anomalies1[col]), mode='markers', name='Anomaly'))
fig.update_layout(showlegend=True, title='Detected anomalies')
fig.show()
print ("######################################################")
####################### PM1 ########################### Testing shape: (134, 864, 1) 1/5 [=====>........................] - ETA: 0s - loss: 0.3507 - mse: 0.1780 - rmse: 0.3507
<ipython-input-17-e1f1d6df3b5c>:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy test[col] = scaler.fit_transform(test[[col]])
5/5 [==============================] - 0s 73ms/step - loss: 0.7559 - mse: 0.8380 - rmse: 0.7559 evaluate: [0.7558709979057312, 0.8379917144775391, 0.7558708190917969] GRU: Mean Absolute Error: 0.7856 Root Mean Square Error: 1.0235 Mean Square Error: 1.0476
anomalies: (134, 10)
###################################################### ####################### PM25 ########################### Testing shape: (134, 864, 1) 1/5 [=====>........................] - ETA: 0s - loss: 0.3310 - mse: 0.1570 - rmse: 0.3310
<ipython-input-17-e1f1d6df3b5c>:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
5/5 [==============================] - 0s 79ms/step - loss: 0.7623 - mse: 0.8503 - rmse: 0.7623 evaluate: [0.7622984647750854, 0.8503379821777344, 0.7623004913330078] GRU: Mean Absolute Error: 0.7876 Root Mean Square Error: 1.0211 Mean Square Error: 1.0427
anomalies: (134, 10)
###################################################### ####################### PM10 ########################### Testing shape: (134, 864, 1) 1/5 [=====>........................] - ETA: 0s - loss: 0.4020 - mse: 0.1961 - rmse: 0.4020
<ipython-input-17-e1f1d6df3b5c>:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
5/5 [==============================] - 0s 84ms/step - loss: 0.7651 - mse: 0.8116 - rmse: 0.7651 evaluate: [0.7650548219680786, 0.8116297125816345, 0.7650539875030518] GRU: Mean Absolute Error: 0.8121 Root Mean Square Error: 1.0189 Mean Square Error: 1.0382
anomalies: (134, 10)
###################################################### ####################### PM1ATM ########################### Testing shape: (134, 864, 1) 1/5 [=====>........................] - ETA: 0s - loss: 0.3506 - mse: 0.1776 - rmse: 0.3506
<ipython-input-17-e1f1d6df3b5c>:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
5/5 [==============================] - 0s 82ms/step - loss: 0.7558 - mse: 0.8375 - rmse: 0.7558 evaluate: [0.7558409571647644, 0.8375365138053894, 0.7558404803276062] GRU: Mean Absolute Error: 0.7861 Root Mean Square Error: 1.0235 Mean Square Error: 1.0475
anomalies: (134, 10)
###################################################### ####################### PM25ATM ########################### Testing shape: (134, 864, 1)
<ipython-input-17-e1f1d6df3b5c>:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
5/5 [==============================] - 0s 87ms/step - loss: 0.7623 - mse: 0.8503 - rmse: 0.7623 evaluate: [0.7622984647750854, 0.8503379821777344, 0.7623004913330078] GRU: Mean Absolute Error: 0.7876 Root Mean Square Error: 1.0211 Mean Square Error: 1.0427
anomalies: (134, 10)
###################################################### ####################### PM10ATM ########################### Testing shape: (134, 864, 1)
<ipython-input-17-e1f1d6df3b5c>:8: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
5/5 [==============================] - 0s 88ms/step - loss: 0.7648 - mse: 0.8110 - rmse: 0.7648 evaluate: [0.7648157477378845, 0.8110335469245911, 0.7648143172264099] GRU: Mean Absolute Error: 0.8126 Root Mean Square Error: 1.0191 Mean Square Error: 1.0385
anomalies: (134, 10)
######################################################